package com.example.demo.navigation.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import java.util.List;

//@Entity
@Table(name = "sys_nav")
public class NavBean3 {

    /**
     * title : 基本元素
     * icon : fa-cubes
     * spread : true
     * children : [{"title":"按钮","icon":"&#xe641;","href":"button.html"},{"title":"表单","icon":"&#xe63c;","href":"form.html"},{"title":"表格","icon":"&#xe63c;","href":"table.html"},{"title":"导航","icon":"&#xe609;","href":"nav.html"},{"title":"Tab选项卡","icon":"&#xe62a;","href":"tab.html"},{"title":"辅助性元素","icon":"&#xe60c;","href":"auxiliar.html"}]
     * href :
     */

    @Id
    @GeneratedValue
//    @JsonIgnore
    private long id;

    @Size(min = 1,max = 10)
    private String title;


    private String icon;

    /**
     * 是否选中
     */
    private Boolean spread;
    private String href;



    @JsonIgnore
    private int sort;

    /**
     * 类型 0 一级 1 二级 2 三级
     */
    @JsonIgnore
    @Min(0)
    @Max(2)
    private int type;


    //XXX 这里应该做个编辑判断
    @JsonIgnore
    private int parentId;

    @Transient
    private List<NavBean3> children;


    public Boolean getSpread() {
        return spread;
    }

    public void setSpread(Boolean spread) {
        this.spread = spread;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }



    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getIcon() {
        if (icon==null||icon.isEmpty())
        {
            return "fa-cubes";
        }
        return icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }

    public boolean isSpread() {
        return spread;
    }

    public void setSpread(boolean spread) {
        this.spread = spread;
    }

    public String getHref() {
        return href;
    }

    public void setHref(String href) {
        this.href = href;
    }

    public List<NavBean3> getChildren() {
        return children;
    }

    public void setChildren(List<NavBean3> children) {
        this.children = children;
    }


}
